
<title>添加内容</title>

<div class="layui-card layadmin-header">
  <div class="layui-breadcrumb" lay-filter="breadcrumb">
    <a lay-href="">主页</a>
    <a><cite>添加内容</cite></a>
  </div>
</div>

<div class="layui-fluid">
  <div class="layui-card">
    <div class="layui-card-body" style="padding: 15px;">
      <form class="layui-form" action="" lay-filter="form-data">
        <div class="layui-form-item">
          <label class="layui-form-label">标题</label>
          <div class="layui-input-block">
            <input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="请输入标题" class="layui-input">
          </div>
        </div>       
        <div class="layui-form-item">
            <label class="layui-form-label">来源</label>
            <div class="layui-input-block">
              <input type="text" name="source" lay-verify="source" autocomplete="off" placeholder="请输入来源" class="layui-input">
            </div>
          </div> 
        <div class="layui-form-item layui-form-text">
          <label class="layui-form-label">简介</label>
          <div class="layui-input-block">
            <textarea name="text" placeholder="请输入简介" class="layui-textarea"></textarea>
          </div>
        </div>        
        <div class="layui-form-item">
          <div class="layui-input-block">
            <div class="layui-footer">
              <button class="layui-btn" lay-submit="" lay-filter="data-add">立即提交</button>
              <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
          </div>
        </div>
      </form>
    </div>
  </div>
</div>

<script>
layui.use(['admin', 'form', 'laydate'], function(){
  var $ = layui.$
  ,admin = layui.admin
  ,element = layui.element
  ,layer = layui.layer
  ,laydate = layui.laydate
  ,form = layui.form;
  
  form.render(null, 'form-data');
  
  /* 自定义验证规则 */
  form.verify({
    title: function(value){
        if(!value) return '请输入名称！';

        if(value.length < 5) return '名称至少得5个字符!';
    },
    source: function(value){
        if(!value) return '请输入来源！';
    },
    user_name: function(value){
        if(!value) return '请选择负责人！';
    }
    ,content: function(value){
      layedit.sync(editIndex);
    }
  });
});
</script>